//
//  TouristViewController.m
//  LocomotiveGuards
//
//  Created by admin on 15/11/18.
//  Copyright (c) 2015年 REDOOR. All rights reserved.
//

#import "TouristViewController.h"
#import "OneViewController.h"
#import "TwoViewController.h"
#import "ThreeViewController.h"
#import "FourViewController.h"

@interface TouristViewController ()
{
    OneViewController *nav1;
    TwoViewController *nav2;
    ThreeViewController *nav3;
    FourViewController *nav4;
}

@end

@implementation TouristViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(changetabbarone1:) name:@"changetabbarone1" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(changetabbartwo1:) name:@"changetabbartwo1" object:nil];
    [self configTab];
}

-(void)configTab{
    nav1=[OneViewController new];
    nav2=[TwoViewController new];
    nav3=[ThreeViewController new];
    nav4=[FourViewController new];
    nav1.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"位置" image:[UIImage imageNamed:@"newtabicon01"] selectedImage:[[UIImage imageNamed:@"newtabicon01_on"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    nav2.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"安全" image:[UIImage imageNamed:@"newtabicon02"] selectedImage:[[UIImage imageNamed:@"newtabicon02_on"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
      
    nav3.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"自助110" image:[UIImage imageNamed:@"newtabicon03"] selectedImage:[[UIImage imageNamed:@"newtabicon03_on"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    nav4.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"设置" image:[UIImage imageNamed:@"newtabicon04"] selectedImage:[[UIImage imageNamed:@"newtabicon04_on"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [self.tabBar setTintColor:[UIColor whiteColor]];
    [self.tabBar setBackgroundImage:[UIImage imageNamed:@"tabback"]];
    
    self.viewControllers=[NSArray arrayWithObjects:nav1,nav2,nav3,nav4, nil];
}

-(void)changetabbarone1:(NSNotification *)data{
    //改变tabbbar状态1
    nav1.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"位置" image:[[UIImage imageNamed:@"new2tabicon01"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"new2tabicon01_on"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    nav2.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"安全" image:[[UIImage imageNamed:@"new2tabicon02"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"new2tabicon02_on"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    nav3.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"自助110" image:[[UIImage imageNamed:@"new2tabicon03"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"new2tabicon03_on"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    nav4.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"设置" image:[[UIImage imageNamed:@"new2tabicon04"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"new2tabicon04_on"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    NSDictionary *dic=data.userInfo;
    self.selectedIndex=[[dic objectForKey:@"key"]integerValue];
    
    [nav1.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithRed:(CGFloat)21/255 green:(CGFloat)124/255 blue:(CGFloat)244/255 alpha:1.0]} forState:UIControlStateNormal];
    [nav2.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithRed:(CGFloat)21/255 green:(CGFloat)124/255 blue:(CGFloat)244/255 alpha:1.0]} forState:UIControlStateNormal];
    [nav3.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithRed:(CGFloat)21/255 green:(CGFloat)124/255 blue:(CGFloat)244/255 alpha:1.0]} forState:UIControlStateNormal];
    [nav4.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithRed:(CGFloat)21/255 green:(CGFloat)124/255 blue:(CGFloat)244/255 alpha:1.0]} forState:UIControlStateNormal];
    
    [self.tabBar setTintColor:[UIColor colorWithRed:(CGFloat)21/255 green:(CGFloat)124/255 blue:(CGFloat)244/255 alpha:1.0]];
    [self.tabBar setBackgroundImage:[UIImage imageNamed:@"tabbackview2"]];
}
-(void)changetabbartwo1:(NSNotification *)data{
    //改变tabbar状态2
    nav1.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"位置" image:[[UIImage imageNamed:@"newtabicon01"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"newtabicon01_on"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    nav2.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"安全" image:[[UIImage imageNamed:@"newtabicon02"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"newtabicon02_on"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    nav3.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"自助110" image:[[UIImage imageNamed:@"newtabicon03"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"newtabicon03_on"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    nav4.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"设置" image:[[UIImage imageNamed:@"newtabicon04"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"newtabicon04_on"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    [nav1.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]} forState:UIControlStateNormal];
    [nav2.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]} forState:UIControlStateNormal];
    [nav3.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]} forState:UIControlStateNormal];
    [nav4.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]} forState:UIControlStateNormal];

    
    NSDictionary *dic=data.userInfo;
    self.selectedIndex=[[dic objectForKey:@"key"]integerValue];
    [self.tabBar setTintColor:[UIColor whiteColor]];
    [self.tabBar setBackgroundImage:[UIImage imageNamed:@"tabback"]];
    
    
}
- (void)dealloc{
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
